*** Settings ***
Documentation    TC05-Column Maintenance FCL
Resource    ../../Keywords/Common_Head.robot
Force Tags    P3
Metadata    Author    Momo
Metadata    ID    6853421


*** Test Cases ***
TC05-Column Maintenance FCL
    Step 1 User Goes To Basic Data Management Tender List
    Step 2 User Goes To Pricing Collaboration Pricing Project
    Step 3 Input Following Attributes
    Step 4 User Selects Row That Project Name Is Tender ID FCL
    Step 5 Click On Copy Data
    Step 6 Input Tender ID With Value 2024000001 Click On Search
    Step 7 Select This Entry Click On Copy Data Button And Yes In
    Step 8 Select Current Project In Pricing Project Click On
    Step 9 Click Skip Button In Step4 and Yes In The Pop up
    Step 10 User Clicks Next Round Management Button
    Step 11 User Clicks Column Maintenance Button
    Step 12 User Selects Some Check Boxes Unchecked And Update Some
    Step 13 User Clicks Download Button
    Step 14 User Opens The Download Document
    Step 15 In Pricing Project Page User Selects TenderID Contains
    Step 16 Select This Project Click On Delete Project Button
    Step 17 User Goes To Basic Data Management Tender List 2



*** Keywords ***
Step ${step} User Goes To Basic Data Management Tender List
    #************************Step 1******************************
    #  Do:
    #      User goes to Basic Data Management Tender List
    #      Click Create button
    #      Input with following attributes
    #      Tender ID some numbers such as 202408151435001 you can
    #     input with current datetime and some random number to
    #     avoid duplicate validation
    #      Tender Title some value such as Regression Test by
    #     Wendy001
    #      Customer 815 Miele
    #      Mode select all
    #      Level Global
    #      Click on Save button
    #  Expected:
    #      Created successfully with the message Tender has been
    #     added
    #************************************************************
    ${G_TENDERID}    Generate Tender ID
    ${TenderTitle}   Set Variable    Regression Test by auto
    Set Suite Variable     ${G_TENDERID}
    Login Space
    Create Tender    ${G_TENDERID}    ${TenderTitle}    815    true    true    true
    ${PROJECT}    Copy Dictionary    ${PROJECT_PARAM}
    Set To Dictionary    ${PROJECT}
    ...    TENDER_ID=${G_TENDERID}    TENDER_TITLE=${TenderTitle}    CUSTOEMR_NAME=Miele    CUSTOMER_LEVEL=Global
    ...   MODE=FCL    DEPUTY=SNOWLI01    TEMPLATE=${CURDIR}${/}TestData${/}FCLTemplate-Location-All.xlsx
    Set Suite Variable     ${PROJECT}

Step ${step} User Goes To Pricing Collaboration Pricing Project
    #************************Step 2******************************
    #  Do:
    #      User goes to Pricing Collaboration Pricing Project
    #      User clicks Create Project button
    #  Expected:
    #      A New Project dialog should be opened successfully
    #************************************************************
    Create Project    ${PROJECT}

Step ${step} Input Following Attributes
    #************************Step 3******************************
    #  Do:
    #      Input following attributes
    #      Tender ID 20240815 Regression
    #      Mode FCL
    #      Deadline to TM current date 10 day
    #      Rate Validity From current date
    #      Rate Validity To current date 100 day
    #      Deputies NATZHANG
    #      Description for regression
    #      Click on Save button
    #  Expected:
    #      A new project is created successfully
    #************************************************************
    Log    Done in step 3

Step ${step} User Selects Row That Project Name Is Tender ID FCL
    #************************Step 4******************************
    #  Do:
    #      User selects row that project name is 20240815 FCL
    #     Regression
    #  Expected:
    #      The row can be selected successfully
    #************************************************************
    Search Project    ${PROJECT.TENDER_ID}

Step ${step} Click On Copy Data
    #************************Step 5******************************
    #  Do:
    #      Click on Copy Data
    #  Expected:
    #      A dialogue named Copy Target to Project 20240815 FCL
    #     Regression display
    #      Search Criteria
    #      Mode with value FCL uneditable
    #      Customer name with no value
    #      Tender ID with value ALL Editable
    #      Tender Lead with value ALL Editable
    #      RFQ Launch Date with value DD MM YYYY Editable
    #      Search button
    #      Result list has no entry present
    #      Copy Data button is disable now
    #************************************************************
    Copy Data    2024000001    FCL    do not touch me

Step ${step} Input Tender ID With Value 2024000001 Click On Search
    #************************Step 6******************************
    #  Do:
    #      Input Tender ID With Value 2024000001 Click On Search
    #     button
    #  Expected:
    #      index php attachments get bbed6818 f35c 4750 983e
    #     8bad0a53a928
    #      Result list has one entry as above information
    #************************************************************
    Log    finish in 'Copy Data' Keyword

Step ${step} Select This Entry Click On Copy Data Button And Yes In
    #************************Step 7******************************
    #  Do:
    #      Select this entry click on Copy Data button and Yes in
    #     pop up window
    #  Expected:
    #      Successfully with messages in pop up window
    #      Tender has been successfully copied from 2024000001 FCL
    #     do not touch me
    #      Please adjust the template and the lanes in Template
    #     Lane Management page if required
    #      After click on OK button
    #      The same message is displayed in Pricing Project page
    #     too
    #************************************************************
    Log    finish in 'Copy Data' Keyword

Step ${step} Select Current Project In Pricing Project Click On
    #************************Step 8******************************
    #  Do:
    #      Select current project in pricing project click on
    #     template management button
    #  Expected:
    #      In the dialog check the information under Step2 should
    #     be the same as project 2024000001 FCL do not touch me
    #************************************************************
    Search Project    ${PROJECT.TENDER_ID}  
    Wait Until Search Finished
    Wait Until Keyword Succeeds    5x    300ms    Click    ${Project_toolbar_TemplateManagementButton}
    Sleep    2
    Get Checkbox State    //span[contains(text(),'Origin items')]/../..//input    ==    checked
    ${value}    get Text    ((//label[contains(.,'TBN')])[1]/../div/div//input)[9]
    Should Be Equal    ${value}    CURRENCY
    Click    ${Template_OriginLocalChargesTab}
    Get Checkbox State    //label[contains(.,'DB Schenker offer free time in days(Calendar Da ...')]//input    ==    checked
    ${value}    get Text    ((//label[contains(.,'TBN')])[2]/../div/div//input)[6]
    Should Be Equal    ${value}    2
    Click    ${Template_RelatedOriginChargesTab}
    Get Checkbox State    //label[contains(.,"Free in Charge (if applicable)")]/../../div//span[contains(text(),"40'/40HQ")]/../..//input[1]    ==    checked
    Click    ${Template_OceanTransportChargesTab}
    Get Checkbox State    //span[contains(text(),'Main Leg Origin / POL')]/../..//input    ==    checked
    ${value}    get Text    ((//label[contains(.,'TBN')])[3]/../div/div//input)[14]
    Should Be Empty    ${value}
    Click   ${Template_DemurrageDetentionTab}
    Get Checkbox State    //label[contains(.,"DB SCHENKER Destination Demurrage")]/../../div//span[contains(text(),"Free Time at Destination 40'/40HQ (Calendar Days)")]/../..//input[1]    ==    checked
    Click    ${Template_RelatedDestinationChargesTab}
    Get Checkbox State    //label[contains(.,"Terminal Security Charge Destination")]/../../div//label[contains(.,'Flat Fee')]/../..//input    ==    checked
    Click    ${Template_DestinationLocalChangesTab}
    Get Checkbox State    //label[contains(.,'Transit Time From CY/RP/ICD to City in Days')]/../..//input    ==    checked
    ${value}    get Text    ((//label[contains(.,'TBN')])[4]/../div/div//input)[18]
    Should Be Equal    ${value}    currency

Step ${step} Click Skip Button In Step4 and Yes In The Pop up
    #************************Step 9******************************
    #  Do:
    #      Click Skip button in Step4 and Yes in the pop up
    #     windown
    #  Expected:
    #      Next Round Management button is enable
    #************************************************************
    Click    ${Template_SkipSendToGPDButton}
    Check Text Value    ${SkipSendToGPDMessage}    Are you sure to skip push pricing?
    Click    ${SkipSendToGPD_Yes}
    Wait Until Search Finished
    Wait Until Keyword Succeeds   20x    500ms    Get Element States    ${Template_gotoNextButton}    contains    visible    enabled

Step ${step} User Clicks Next Round Management Button
    #************************Step 10******************************
    #  Do:
    #      User clicks Next round management button
    #  Expected:
    #      A dialogue named Project 20240815 FCL Regression Round1
    #     display
    #      It divides into 5 parts
    #      1 Generation Information current Pricing Round 1
    #     Started 2 lanes
    #      2 Assignment
    #      3 Attached Document
    #      4 Round History
    #      5 The tasks status Region Country My tasks
    #************************************************************
    Click Next Round Management Dialog And Check

Step ${step} User Clicks Column Maintenance Button
    #************************Step 11******************************
    #  Do:
    #      User clicks column maintenance button
    #  Expected:
    #      A dialogue named column maintenance display
    #      All of the options are checked
    #************************************************************
    Click    ${Project_RoundMgmt_ColMaintainButton}
    Wait Until Search Finished
    Get Checkbox State    //span[contains(text(),'Origin items')]/../..//input    ==    checked
    ${value}    get Text    ((//label[contains(.,'TBN')])[1]/../div/div//input)[9]
    Should Be Equal    ${value}    CURRENCY
    Click    ${Template_OriginLocalChargesTab}
    Get Checkbox State    //label[contains(.,'DB Schenker offer free time in days(Calendar Da ...')]//input    ==    checked
    ${value}    get Text    ((//label[contains(.,'TBN')])[2]/../div/div//input)[6]
    Should Be Equal    ${value}    2
    Click    ${Template_RelatedOriginChargesTab}
    Get Checkbox State    //label[contains(.,"Free in Charge (if applicable)")]/../../div//span[contains(text(),"40'/40HQ")]/../..//input[1]    ==    checked
    Click    ${Template_OceanTransportChargesTab}
    Get Checkbox State    //span[contains(text(),'Main Leg Origin / POL')]/../..//input    ==    checked
    ${value}    get Text    ((//label[contains(.,'TBN')])[3]/../div/div//input)[14]
    Should Be Empty    ${value}
    Click   ${Template_DemurrageDetentionTab}
    Get Checkbox State    //label[contains(.,"DB SCHENKER Destination Demurrage")]/../../div//span[contains(text(),"Free Time at Destination 40'/40HQ (Calendar Days)")]/../..//input[1]    ==    checked
    Click    ${Template_RelatedDestinationChargesTab}
    Get Checkbox State    //label[contains(.,"Terminal Security Charge Destination")]/../../div//label[contains(.,'Flat Fee')]/../..//input    ==    checked
    Click    ${Template_DestinationLocalChangesTab}
    Get Checkbox State    //label[contains(.,'Transit Time From CY/RP/ICD to City in Days')]/../..//input    ==    checked
    ${value}    get Text    ((//label[contains(.,'TBN')])[4]/../div/div//input)[18]
    Should Be Equal    ${value}    currency

Step ${step} User Selects Some Check Boxes Unchecked And Update Some
    #************************Step 12******************************
    #  Do:
    #      User selects some check boxes unchecked and update some
    #     of the value clicks save button
    #  Expected:
    #      The dialogue disappears
    #************************************************************
    Click    ${Template_FCL_CustomerDataTab}
    Fill Text    ((//label[contains(.,'TBN')])[1]/../div/div//input)[8]    222
    Click    ${Template_OriginLocalChargesTab}
    Click    //label[contains(.,'DB Schenker offer free time in days(Calendar Da ...')]//input
    Click    ${Template_OceanTransportChargesTab}
    Click    //span[contains(text(),'Main Leg Origin / POL')]/../..//input
    Click   ${Template_DemurrageDetentionTab}
    Click    //label[contains(.,"DB SCHENKER Destination Demurrage")]/../../div//span[contains(text(),"Free Time at Destination 40'/40HQ (Calendar Days)")]/../..//input[1]
    Click    ${Template_RelatedDestinationChargesTab}
    Click    //label[contains(.,"Terminal Security Charge Destination")]/../../div//label[contains(.,'Flat Fee')]/../..//input
    Click    ${Template_DestinationLocalChangesTab}
    Click    //label[contains(.,'Transit Time From CY/RP/ICD to City in Days')]/../..//input
    Click    ${Project_ColMaintain_SaveButton}
    Wait Until Search Finished
    Get Element States    //span[contains(.,'Project ${PROJECT.TENDER_ID}-${PROJECT.MODE}-${PROJECT.TENDER_TITLE} Round1')]    contains    visible    enabled

Step ${step} User Clicks Download Button
    #************************Step 13******************************
    #  Do:
    #      User clicks download button
    #  Expected:
    #      The internal pricing template download successfully
    #************************************************************
    Wait Until Search Finished
    ${filename}    Download File    //b[contains(text(),'Internal Pricing Template')]/..//button[.='Download']
    Set Suite Variable    ${filename}    ${filename}
    Wait Until Search Finished

Step ${step} User Opens The Download Document
    #************************Step 14******************************
    #  Do:
    #      User opens the download document
    #  Expected:
    #      The columns of the download file don t have the
    #     unchecked options
    #************************************************************
    Open Excel Document     ${filename}    ${PROJECT.MODE}_D
    ${value1}    Read Excel Cell    3    53
    Should Be Equal    ${value1}    222
    ${row values}    Read Excel Row    3
    Should Not Contain    ${row values}    DB Schenker offer free time in days
    Should Not Contain    ${row values}    Main Leg Origin / POL
    Should Not Contain    ${row values}    Free Time at Destination 40'/40HQ (Calendar Days)
    Should Not Contain    ${row values}    Transit Time From CY/RP/ICD to City in Days
    Close All Excel Documents

Step ${step} In Pricing Project Page User Selects TenderID Contains
    #************************Step 15******************************
    #  Do:
    #      In Pricing Project page User selects TenderID Contains
    #     20240815
    #  Expected:
    #      The project could be found
    #************************************************************
    Click    ${Project_ColMaintain_CloseButton}
    Wait Until Search Finished

Step ${step} Select This Project Click On Delete Project Button
    #************************Step 16******************************
    #  Do:
    #      Select this project click on Delete Project button
    #      Click Yes of the pop up confirm window
    #  Expected:
    #      System displays Project has been deleted
    #************************************************************
    Delete Project    ${G_TENDERID}

Step ${step} User Goes To Basic Data Management Tender List 2
    #************************Step 17******************************
    #  Do:
    #      User goes to Basic Data Management Tender List
    #      Search out the tender created in step1
    #      Click on Delete button
    #      Click on Yes button in the popup dialog
    #  Expected:
    #      System displays Tender has been deleted
    #************************************************************
    Delete Tender    ${G_TENDERID}

